get key with maximum or minimum value from dictionary